<?php 
  // function test(){
  // 	echo "this is a test";
  // 	exit();
  // }
 function uploadfile($field,$tsize=150){
        $config = array(
            'maxSize'    =>    3145728,
            'rootPath'   =>    './Public/Uploads/',
            'savePath'   =>    '',
            'saveName'   =>    array('uniqid',''),
            'exts'       =>    array('jpg', 'gif', 'png', 'jpeg'),
            'autoSub'    =>    true,
            'subName'    =>    array('date','Ymd'),
        );

        $upload = new \Think\Upload($config);// 实例化上传类
        $upload->saveName = time().'_'.mt_rand();
        // 上传单个文件 
        $info   =   $upload->uploadOne($_FILES[$field]);
        if(!$info) {// 上传错误提示错误信息
            $this->error($upload->getError());
        }else{// 上传成功 获取上传文件信息
             $image = new \Think\Image(); 
             $image->open($config['rootPath'].$info['savepath'].$info['savename']);
             $image->thumb($tsize, $tsize,3)->save($config['rootPath'].$info['savepath'].'thumb_'.$info['savename']);

             return $info['savepath'].'thumb_'.$info['savename'];
        }
    }
?>